<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>

<!DOCTYPE HTML>
<html>
<head>
<base href="<%=basePath%>">

<title>雨量监测系统首页</title>
<link rel="stylesheet" type="text/css" href="css/style.css">
<script type="text/javascript" src="js/jquery-3.4.0.js"></script>
</head>

<c:if test="${empty rmList && empty isSelect }">
	<c:redirect url="RS?type=select" />
</c:if>

<body>
	<div class="body">
		<h1>雨量监测信息</h1>
		<table>
			<tr>
				<th>序号</th>
				<th>区域名称</th>
				<th>检测时间</th>
				<th>雨量值（mm）</th>
				<th>检测站</th>
				<th>站点地址</th>
				<th>操作</th>
			</tr>
			<c:forEach items="${rmList }" var="rm">
				<tr>
					<th class="id">${rm.id }</th>
					<th>${rm.districtName }</th>
					<th>${rm.monitorTime }</th>
					<th>${rm.rain }</th>
					<th>${rm.monitoringStation }</th>
					<th>${rm.monitoringAddress }</th>
					<th><a href="javascript:">删除</a></th>
				</tr>
			</c:forEach>
		</table>

		<a href="addRain.jsp">新增雨量监测信息</a>
	</div>
	<script type="text/javascript">
		$(function(){
			//$("tr:even").css("background","gray");
			$("a[href^='java']").click(function(){
				var fix = confirm("确定删除么？");
				if(fix == true){
					var tr =  $(this).parent().parent();
					var id = tr.children(".id").html();
					$.ajax({
						url:"RS",
						type:"post",
						data:"type=delete&id="+id,
						dataType:"text",
						success:function(data){
							//alert(data);
							if(data == "true"){
								alert("删除成功！");
								tr.remove();
								
								location.reload();
							}else{
								alert("删除失败！");
							}
						}
					});
					
				}else{
					return false;
				}
			});
		});
	
	</script>
</body>
</html>
